{extend name="../../admin/view/main"}


{block name='content'}
<form action="{:sysuri()}" class="layui-card layui-form" data-auto="true" method="post">
    <div class="layui-card-body">

        <label class="layui-form-item relative block">
            <span class="help-label"><b>标题</b></span>
            <input class="layui-input" name="title" placeholder="请输入标题" required value='{$vo.title|default=""}'>
        </label>



        <div class="layui-form-item" id="content-div">
            <span class="help-label"><b>公示详情</b></span>
            <div class="relative block">
                <textarea class="layui-hide" name="content" placeholder="请输入公示详情">{$vo.content|default=''}</textarea>
            </div>
        </div>


        <div class="layui-form-item">
            <div style="float: left;min-width: auto;height: 38px;line-height: 38px;">
                <span class="help-label" style="padding-right: 40px;"><b>公示日期</b></span>
            </div>
            <div style="float: left;">
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" name="ctrq" id="ctrq" required value="{$vo.ctrq|default=''}" placeholder="请选择公示日期">
                </div>
            </div>
        </div>

        <div class="layui-col-xs12">
            <span class="help-label"><b>免申即享内容</b></span>
            <span class="color-desc margin-left-5"></span>
            <div id="peipeiList" class="xm-select-demo" ></div>
            <input type="hidden" name="msjx_ids" id="msjx_ids"  value="{$vo.msjx_ids|default=''}">
        </div>

        <label class="layui-form-item relative block" style="margin-top: 10px">
            <span class="help-label"><b>责任单位</b></span>
            <input class="layui-input" name="fbdw" placeholder="请输入责任单位" required value='{$vo.fbdw|default=""}'>
        </label>





        <div class="hr-line-dashed"></div>
        {notempty name='vo.id'}<input name='id' type='hidden' value='{$vo.id}'>{/notempty}

        <div class="layui-form-item text-center">
            <button class="layui-btn" type="submit">保存数据</button>
            <button class="layui-btn layui-btn-danger" data-history-back data-confirm="确定要取消编辑吗？" type='button'>取消编辑</button>
        </div>
    </div>

</form>
<script>
    layui.use(function(){
        var laydate = layui.laydate;
        // 渲染
        laydate.render({
            elem: '#ctrq'
        });

    });

    $(function () {
        getMsjxList();
    });


    function getMsjxList() {
        layui.use('xmSelect', function () {
            $.ajax({
                type: 'get',
                url: "{:url('getMsjxList')}",
                data: "",
                dataType: "json",
                success: function (res) {
                    if (res.code) {
                        console.log(res);
                        var datas = [];
                        res.data.forEach(function (item) {
                            var uuid = "{$vo.msjx_ids|default=''}".split(',');
                            if (uuid.length && uuid.findIndex(it => it == item.id) != -1) {
                                datas.push({name: item.title, value: item.id, selected: true});

                            } else {
                                datas.push({name: item.title, value: item.id});
                            }
                        });
                        xmSelect.render({
                            el: '#peipeiList',
                            tips: '请选择免申即享内容',//选项提示文字
                            filterable: true,//搜索模式
                            data: datas,
                            on: function (data) {
                                var selectArr = data.arr;
                                var seachArr = [];
                                for (var j = 0; j < selectArr.length; j++) {
                                    seachArr.push(selectArr[j].value)
                                }
                                $("#msjx_ids").val(seachArr.toString());
                            }
                        })
                    } else {
                        console.log(res.info);
                    }
                },
                error: function (err) {
                    console.log(err)
                }
            });
        });
    }
</script>

<script>

    require(['ckeditor'], function () {
        window.createEditor('[name=content]', {height: 350})
    });

</script>
{/block}
